
Ext.Loader.setConfig({enabled: true});


Ext.Loader.setPath('Ext.ux', '../../../otherscript/extjs/examples/ux');

Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.grid.plugin.BufferedRenderer',
    'Ext.ux.form.SearchField',
	'Ext.ux.grid.FiltersFeature',
	'Ext.toolbar.Paging',
	'Ext.ux.ajax.JsonSimlet',
    'Ext.ux.ajax.SimManager'
]);



    
    
    

Ext.onReady(function(){
	
	
  
    Ext.define('cfbose.exitinterviewmonitoring', {
        extend: 'Ext.data.Model',
        fields: [
            'controlnumber', 
			'company',
			'employeenumber',
			{
				name: 'dateofaccomplishment',
				type: 'date'
			}, 
			'nameofemployee', 
			'immediatesuperior',
			'department',
			{
                name: 'age',
                type: 'int'
            },
			'currentposition',
			'positionuponhire',
			{
				name: 'datehired',
				type: 'date'
			},
			{
				name: 'effectdateresign',
				type: 'date'
			},
			'lengthofservice',
			'localopportunity',
			'industrynxtemp',
			'companynxtemp',
			{
				name: 'expectedtomeet',
				type: 'boolean'
			},
			'expectmeetremarks',
			{
				name: 'changesaffected',
				type: 'boolean'
			},
			'changesremarks',
			{
				name: 'developfull',
				type: 'boolean'
			},
			'developfullremarks',
			{
				name: 'answerproblems',
				type: 'boolean'
			},
			'problemsremarks',
			{
				name: 'improvements',
				type: 'boolean'
			},
			'improvementsremarks',
			'factorsfacilitated',
			'factorshindered',
			'comppolicies',
			'comppolicyremarks',
			'compreputation',
			'compreputationremarks',
			'seniorlead',
			'seniorleadremarks',
			'superiorimmed',
			'superiorimmedremarks',
			'coworkers',
			'coworkersremarks',
			'customers',
			'customersremarks',
			'salary',
			'salaryremarks',
			'benefits',
			'benefitsremarks',
			'perfmgnt',
			'perfmgntremarks',
			'recognition',
			'recognitionremarks',
			'workk',
			'workremarks',
			'resourcespeople',
			'resourcespeopleremarks',
			'empcommu',
			'empcommuremarks',
			'workprocess',
			'workprocessremarks',
			'careeropp',
			'careeroppremarks',
			'traindevopp',
			'traindevoppremarks',
			'worklifebal',
			'worklifebalremarks',
			'workcondition',
			'workconditionremarks',
			'overallwork',
			'overallworkremarks',
			{
				name: 'applyfutureyes',
				type: 'boolean'
			},
			'applyfutureremarks',
			'remarksfinalresignee',
			{
				name: 'resigneeremarkdate',
				type: 'date'
			},
			'rmrksfinterviewer',
			{
				name: 'interviewerrmrkdate',
				type: 'date'
			},
        ],
        idProperty: 'controlnumber'
    });

    // create the Data Store
    var store = Ext.create('Ext.data.Store', {
        id: 'store',
        model: 'cfbose.exitinterviewmonitoring',
        remoteGroup: true,
		remoteSort: true,
		buffered: true,
        leadingBufferZone: 1,
        pageSize: 20,
        proxy: {
            type: 'jsonp',
            url: '../../../app/controller/clearance/exitinterview/exitmonitoringdata.cfm',
            reader: {
                root: 'topics',
                totalProperty: 'totalCount'
            },
			simpleSortMode: true,
			simpleGroupMode: true,
			groupParam: 'sort',
            groupDirectionParam: 'dir',
			filterParam: 'query',

            encodeFilters: function(filters) {
                return filters[0].value;
			}
			
        },
		sorters: [{
            property: 'dateofaccomplishment',
            direction: 'DESC'
        }],

		remoteFilter: true,
        autoLoad: true,
        listeners: {

            // This particular service cannot sort on more than one field, so if grouped, disable sorting
            groupchange: function(store, groupers) {
                var sortable = !store.isGrouped(),
                    headers = grid.headerCt.getVisibleGridColumns(),
                    i, len = headers.length;
                
                for (i = 0; i < len; i++) {
                    headers[i].sortable = (headers[i].sortable !== undefined) ? headers[i].sortable : sortable;
                }
            },

            // This particular service cannot sort on more than one field, so if grouped, disable sorting
            beforeprefetch: function(store, operation) {
                if (operation.groupers && operation.groupers.length) {
                    delete operation.sorters;
                }
            }
        }
    });
	
	function onStoreSizeChange() {
        grid.down('#status').update({count: store.getTotalCount()});
    }

    function renderTopic(value, p, record) {
        return Ext.String.format(
            '<b>{0}</b>',
            value,
            record.data.forumtitle,
            record.getId(),
            record.data.forumid
        );
    }
	
	var filters = {
        ftype: 'filters',
        // encode and local configuration options defined previously for easier reuse
        encode: false, // json encode the filter query
        local: false,   // defaults to false (remote filtering)

        // Filters are most naturally placed in the column definition, but can also be
        // added here.
        filters: [{
            type: 'numeric',
            dataIndex: 'age'
        }]
    };
	
	
	//for company lookup
	Ext.define('CompanyLK', {
		extend: 'Ext.data.Model',
		fields: [{
			name: 'companycode',
			type: 'string'
		},{
			name: 'companyname',
			type: 'string'
		}]
	});	
	//for department lookup
	Ext.define('DepartmentLK', {
		extend: 'Ext.data.Model',
		fields: [{
			name: 'departmentcode',
			type: 'string'
		},{
			name: 'departmentname',
			type: 'string'
		}]
	});	
	//for position
	Ext.define('PositionLK', {
		extend: 'Ext.data.Model',
		fields: [{
			name: 'positioncode',
			type: 'string'
		},{
			name: 'positionname',
			type: 'string'
		}]
	});
	var companylk =	Ext.create('Ext.data.Store', {
						model: 'CompanyLK',
						proxy: {
							type: 'ajax',
							url: '../../../data/lookup/companydsn.cfm',
							reader: {
								type: 'json',
								root: 'companylk'
							}
							
						},
						autoLoad: true
					    
				   });
    var departmentlk =	Ext.create('Ext.data.Store', {
						model: 'DepartmentLK',
						proxy: {
							type: 'ajax',
							url: '../../../data/lookup/department.cfm',
							reader: {
								type: 'json',
								root: 'departmentlk'
							}
							
						},
						autoLoad: true
					    
				   });
		
    var positionlk =	Ext.create('Ext.data.Store', {
							model: 'PositionLK',
							proxy: {
								type: 'ajax',
								url: '../../../data/lookup/position.cfm',
								reader: {
									type: 'json',
									root: 'positionlk'
								}
								
							},
							autoLoad: true
						    
					   });

	var writetoexcel = function() {
		Ext.Ajax.request({
		    url: '../../../app/controller/clearance/exitinterview/gridtoexcel.cfm',
		    success: function(response){
		        var text = response.responseText;
				var findresult = text.indexOf('writenow');
				if(findresult >= 0) {
					
					window.location.href = "../../../app/controller/clearance/exitinterview/ExitInterviewData.xls";
					
				} else {
					Ext.Msg.show({
		  				title: 'Failed to export to excel',
		  				msg: 'There is a problem in exporting the record to excel' + text,
		  				buttons: Ext.Msg.OK,
		  				icon: Ext.Msg.ERROR
		  			});
				}
				
				//window.location.reload(); --> use this command only if you attempt to force the page refresh
				
		    }
		});
	}
	
	var graphimpromvent = function() {
		
/*
var store = Ext.create('Ext.data.JsonStore', {
		    fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
		    data: [
		        {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8},
		        {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10},
		        {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12},
		        {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1},
		        {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13}
		    ]
		});
*/


		Ext.define('ImprovementGraph', {
		extend: 'Ext.data.Model',
		fields: [{
				name: 'name',
				type: 'string'
			},{
				name: 'very_satisfied',
				type: 'number'
			},{
				name: 'satisfied',
				type: 'number'
			},{
				name: 'dissatisfied',
				type: 'number'
			},{
				name: 'very_dissatisfied',
				type: 'number'
			}]
		});
	    var improvementstore =	Ext.create('Ext.data.Store', {
						model: 'ImprovementGraph',
						
						proxy: {
							type: 'ajax',
							url: '../../../data/graph/improvementgraph.cfm',
							reader: {
								type: 'json',
								root: 'improvementgraph'
							}
							
						},
						autoLoad: true
					    
				   });
				   
		var chart = Ext.create('Ext.chart.Chart', {
		    renderTo: Ext.getBody(),
		    width: 1000,
		    height: 600,
			legend: {
				position: 'bottom'
			},
		    store: improvementstore,
		    axes: [{
		        type: 'Numeric',
		        position: 'left',
		        fields: ['very_satisfied', 'satisfied', 'dissatisfied', 'very_dissatisfied'],
		        title: 'Number',
				minorTickSteps: 1,
		        grid: {
		            odd: {
		                opacity: 1,
		                fill: '#ddd',
		                stroke: '#bbb',
		                'stroke-width': 1
		            }
		        },
		        minimum: 0,
		        adjustMinimumByMajorUnit: 0
		    }, {
		        type: 'Category',
		        position: 'bottom',
		        fields: ['name'],
		        title: 'Reasons for Improvement',
		        grid: true,
		        label: {
		            rotate: {
		                degrees: 320
		            }
		        }
		    }],
		    series: [{
		        type: 'column',
		        highlight: false,
				tips: {
				  trackMouse: true,
				  width: 200,
				  height: 28,
				  renderer: function(storeItem, item) {
				    this.setTitle(storeItem.get('name') + ': ' + storeItem.get('very_satisfied') + ' | ' + storeItem.get('satisfied') + ' | ' + storeItem.get('dissatisfied') + ' | ' + storeItem.get('very_dissatisfied'));
					
				  }
				},
		        axis: 'left',
		        xField: 'name',
		        yField: ['very_satisfied', 'satisfied', 'dissatisfied', 'very_dissatisfied'],
		        style: {
		            opacity: 0.93
		        }
		    }]
		});
		
		Ext.create('Ext.window.Window', {
		    title: 'Areas for Improvement',
			closable: true,
		    height: 600,
		    width: 1300,
		    layout: 'fit',
			tbar: [{
					xtype: 'datefield',
					format: 'n/j/Y',
					id: 'datefromfromdd',
					fieldLabel: 'Date From',
					cls: 'field-margin',
					name: 'datefrom'
				},{
					xtype: 'datefield',
					format: 'n/j/Y',
					id: 'datetotodd',
					fieldLabel: 'Date To',
					cls: 'field-margin',
					name: 'dateto'
				},{
					xtype: 'button',
					cls: 'field-margin',
					text: 'Refresh',
					handler: function() {
						var datefrom = Ext.getCmp('datefromfromdd').getValue();
						var dateto   = Ext.getCmp('datetotodd').getValue();
						
						improvementstore.load({
							scope: this,
							params: {
								datefrom: datefrom,
								dateto: dateto
							}
						})
					}
				}],
			items: chart,
		    
		}).show();
		
	}
	
	var showagraphnow = function() {
		
		Ext.define('ReasonGraph', {
		extend: 'Ext.data.Model',
		fields: [{
				name: 'name',
				type: 'string'
			},{
				name: 'data',
				type: 'number'
			}]
		});
	    var reasongraphstore =	Ext.create('Ext.data.Store', {
						model: 'ReasonGraph',
						
						proxy: {
							type: 'ajax',
							url: '../../../data/graph/reasongraph.cfm',
							reader: {
								type: 'json',
								root: 'reasongraph'
							}
							
						},
						autoLoad: true
					    
				   });
		
	
		
		var chart = Ext.create('Ext.chart.Chart', {
		    renderTo: Ext.getBody(),
			title: '1. What is the main factor that affected your decision to leave the Company?',
		    width: 500,
			height: 350,
		    animate: true,
		    store: reasongraphstore,
		    theme: 'Base:gradients',
			legend: {
				position: 'right'
			},
		    series: [{
		        type: 'pie',
		        angleField: 'data',
		        showInLegend: true,
		        tips: {
		            trackMouse: true,
		            width: 250,
		            height: 28,
		            renderer: function(storeItem, item) {
		                // calculate and display percentage on hover
						 this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data') + ' selected');
		                //var total = 0;
		                //store.each(function(rec) {
		                //    total += storeItem.get('data');
		                //});
		                //this.setTitle(storeItem.get('name') + ': ' + Math.round(storeItem.get('data') / total * 100) + '%');
		            }
		        },
		        highlight: {
		            segment: {
		                margin: 20
		            }
		        },
		        label: {
		            field: 'name',
		            display: 'rotate',
		            contrast: true,
		            font: '18px Arial'
		        }
		    }]
		});
		
		
		Ext.create('Ext.window.Window', {
		    title: '1. What is the main factor that affected your decision to leave the Company?',
			closable: true,
		    height: 600,
		    width: 900,
		    layout: 'fit',
			tbar: [{
					xtype: 'datefield',
					format: 'n/j/Y',
					id: 'datefromfrom',
					fieldLabel: 'Date From',
					cls: 'field-margin',
					name: 'datefrom'
				},{
					xtype: 'datefield',
					format: 'n/j/Y',
					id: 'datetoto',
					fieldLabel: 'Date To',
					cls: 'field-margin',
					name: 'dateto'
				},{
					xtype: 'button',
					cls: 'field-margin',
					text: 'Refresh',
					handler: function() {
						var datefrom = Ext.getCmp('datefromfrom').getValue();
						var dateto   = Ext.getCmp('datetoto').getValue();
						
						reasongraphstore.load({
							scope: this,
							params: {
								datefrom: datefrom,
								dateto: dateto
							},
							//callback: function(records, operation, success) {
						        // the operation object
						        // contains all of the details of the load operation
						        //console.log(records);
						    //} 
						})
					}
				}],
			items: chart,
		    
		}).show();
	}

    var gridexit = Ext.create('Ext.grid.Panel', {
        layout: 'fit',
		height: 500,
		collapsible: true,
        title: 'Exit Interview Monitoring',
		features: [filters],
		plugins: [
	        Ext.create('Ext.grid.plugin.CellEditing', {
	            clicksToEdit: 2
	        })
	    ],
        store: store,
        loadMask: true,
        dockedItems: [{
            dock: 'top',
            xtype: 'toolbar',
            items: [{
                width: 400,
                fieldLabel: 'Search',
                labelWidth: 50,
                xtype: 'searchfield',
                store: store
            }, '->', {
                xtype: 'button',
                itemId: 'graphnow',
                text: 'Graph reasons for leaving',
                style: 'margin-right:5px',
				handler: showagraphnow
            }, '->', {
                xtype: 'button',
                itemId: 'graphareasimprove',
                text: 'Graph areas for improvement',
                style: 'margin-right:5px',
				handler: graphimpromvent
            }, '->', {
                xtype: 'button',
                itemId: 'gridtoexcel',
                text: 'Export to excel',
                style: 'margin-right:5px',
				handler: writetoexcel
            }, '->', {
                xtype: 'component',
                itemId: 'status',
                tpl: 'Matching threads: {count}',
                style: 'margin-right:5px'
            }]
        }],
        selModel: {
            pruneRemoved: false
        },
        multiSelect: false,
        viewConfig: {
            trackOver: false,
            emptyText: '<h1 style="margin:20px">No matching results</h1>'
        },
        // grid columns
        columns:[{
            xtype: 'rownumberer',
			locked: true,
            width: 50,
            sortable: false
        },{
            text: "Control Number",
            dataIndex: 'controlnumber',
			filterable: true,
            width: 100,
            hidden: false,
            sortable: true
        },{
            tdCls: 'x-grid-cell-topic',
            text: "Name of Employee",
			locked: true,
            dataIndex: 'nameofemployee',
            width: 300,
			editor: 'textfield',
            renderer: renderTopic,
            sortable: true,
			filter: {
				type: 'string'
			}
        },{
            text: "Employee Number",
            dataIndex: 'employeenumber',
			editor: 'textfield',
			align: 'center',
            width: 150,
            sortable: true,
			filter: {
				type: 'string'
			}
        },{
			text: 'Date of Accomplishment',
			renderer: Ext.util.Format.dateRenderer('n/j/Y'),
			dataIndex: 'dateofaccomplishment',
			filterable: true,
			align: 'center',
			width: 150,
			sortable: true
		},{
            text: 'Company',
            dataIndex: 'company',
			filterable: true,
            align: 'center',
            width: 300,
            sortable: true,
			editor: {
				store: companylk,
				queryMode: 'server',
				xtype: 'combobox',
				displayField: 'companyname',
				valueField: 'companycode'
			}
        },{
			text: 'Immediate Superior',
			dataIndex: 'immediatesuperior',
			filterable: true,
			editor: 'textfield',
			align: 'center',
			width: 250,
			sortable: true
		},{ 
			text: 'Department',
			dataIndex: 'department',
			filterable: true,
			editor: 'textfield',
			align: 'center',
			width: 250,
			sortable: true,
			editor: {
				store: departmentlk,
				queryMode: 'server',
				xtype: 'combobox',
				displayField: 'departmentname',
				valueField: 'departmentcode'
			}
		},{
			text: 'Age',
			dataIndex: 'age',
			editor: 'numberfield',
			filterable: true,
			align: 'center',
			width: 50,
			sortable: true
		},{
			text: 'Current Position',
			dataIndex: 'currentposition',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true,
			editor: {
				store: positionlk,
				queryMode: 'server',
				xtype: 'combobox',
				displayField: 'positionname',
				valueField: 'positioncode'
			}
		},{
			text: 'Position upon hire',
			dataIndex: 'positionuponhire',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true,
			editor: {
				store: positionlk,
				queryMode: 'server',
				xtype: 'combobox',
				displayField: 'positionname',
				valueField: 'positioncode'
			}
		},{
			text: 'Date hired',
			renderer: Ext.util.Format.dateRenderer('n/j/Y'),
			dataIndex: 'datehired',
			filterable: true,
			align: 'center',
			width: 100,
			sortable: true
		},{
			text: 'Effective date of resignation',
			renderer: Ext.util.Format.dateRenderer('n/j/Y'),
			dataIndex: 'effectdateresign',
			filterable: true,
			editor: 'datefield',
			align: 'center',
			width: 100,
			sortable: true
		},{
			text: 'Length of service',
			dataIndex: 'lengthofservice',
			filterable: true,
			editor: 'textfield',
			align: 'center',
			width: 100,
			sortable: true
		},{
			text: 'Reasons for leaving',
			dataIndex: 'localopportunity',
			filterable: true,
			editor: 'textfield',
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Industry of next employeer',
			dataIndex: 'industrynxtemp',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Company of next employeer',
			dataIndex: 'companynxtemp',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true,
			editor: {
				store: companylk,
				queryMode: 'server',
				xtype: 'combobox',
				displayField: 'companyname',
				valueField: 'companycode'
			}
		},{
			text: '1. Did you understand the performance standards you were expected to meet?',
			dataIndex: 'expectedtomeet',
			xtype: 'booleancolumn', 
			trueText: 'Yes',
            falseText: 'No', 
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '1. Remarks',
			dataIndex: 'expectmeetremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '2. Were you informed about the changes that affected your work?',
			dataIndex: 'changesaffected',
			xtype: 'booleancolumn', 
			trueText: 'Yes',
            falseText: 'No', 
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'changesremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '3. Do you feel you were given a chance to develop your full potential?',
			dataIndex: 'developfull',
			xtype: 'booleancolumn', 
			trueText: 'Yes',
            falseText: 'No', 
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'developfullremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '4. Was your superior willing to answer questions and help you solve problems?',
			dataIndex: 'answerproblems',
			xtype: 'booleancolumn', 
			trueText: 'Yes',
            falseText: 'No', 
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'problemsremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '5. Were you encouraged to offer suggestions and improvements?',
			dataIndex: 'improvements',
			xtype: 'booleancolumn', 
			trueText: 'Yes',
            falseText: 'No', 
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'improvementsremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '6. What factor(s) facilitated the accomplishment of your job?',
			dataIndex: 'factorsfacilitated',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '7. What factor(s) hindered the accomplishment of your job?',
			dataIndex: 'factorshindered',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '1. Company Policies and Practices',
			dataIndex: 'comppolicies',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'comppolicyremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '2. Company Reputation',
			dataIndex: 'compreputation',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'compreputationremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '3. Senior Leadership',
			dataIndex: 'seniorlead',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'seniorleadremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '4. Immediate Superior',
			dataIndex: 'superiorimmed',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'superiorimmedremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '5. Co-workers',
			dataIndex: 'coworkers',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'coworkersremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '6. Customers',
			dataIndex: 'customers',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'customersremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '7. Salary',
			dataIndex: 'salary',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'salaryremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '8. Benefits',
			dataIndex: 'benefits',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'benefitsremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '9. Performance Management',
			dataIndex: 'perfmgnt',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'perfmgntremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '10. Recognition',
			dataIndex: 'recognition',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'recognitionremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '11. Work',
			dataIndex: 'workk',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'workremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '12. Resources (People, Information, Tools, Technology)',
			dataIndex: 'resourcespeople',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'resourcespeopleremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '13. Employee Communication',
			dataIndex: 'empcommu',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'empcommuremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '14. Work Processes',
			dataIndex: 'workprocess',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'workprocessremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '15. Career Opportunities',
			dataIndex: 'careeropp',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'careeroppremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '16. Training and Development Opportunities',
			dataIndex: 'traindevopp',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'traindevoppremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '17. Work/Life Balance',
			dataIndex: 'worklifebal',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'worklifebalremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '18. Working Conditions',
			dataIndex: 'workcondition',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'workconditionremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: '19. Overall Working Experience',
			dataIndex: 'overallwork',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'overallworkremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Are you willing to re-apply in this company in the future?',
			dataIndex: 'applyfutureyes',
			xtype: 'booleancolumn', 
			trueText: 'Yes',
            falseText: 'No', 
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks',
			dataIndex: 'applyfutureremarks',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Remarks of Resigning Employee',
			dataIndex: 'remarksfinalresignee',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Date',
			dataIndex: 'resigneeremarkdate',
			filterable: true,
			renderer: Ext.util.Format.dateRenderer('n/j/Y'),
			align: 'center',
			width: 100,
			sortable: true
		},{
			text: 'Remarks of the Interviewer',
			dataIndex: 'rmrksfinterviewer',
			filterable: true,
			align: 'center',
			width: 300,
			sortable: true
		},{
			text: 'Date',
			dataIndex: 'interviewerrmrkdate',
			filterable: true,
			align: 'center',
			width: 100,
			sortable: true,
			renderer: Ext.util.Format.dateRenderer('n/j/Y'),
		}],
	
        renderTo: Ext.getBody()
    });
	
	gridexit.on('edit', function(editor, e) {
		
		//check if new and old value, disregard saving if the same
		if (e.value == e.originalValue) {
			return true;
		}
		
		Ext.Ajax.request({
		    url: '../../../app/controller/clearance/exitinterview/saveexitmntrdata.cfm',
			params: {
				controlnumber: e.record.data.controlnumber,
				field: e.field,
				value: e.value
			},
			success: function(response){
		        var text = response.responseText;
							
				var findresult = text.indexOf('success');
				if(findresult > 0) {
					return true;
				} else {
					Ext.Msg.show({
		  				title: 'Failed to save!',
		  				msg: 'There is a problem in saving the data' + text,
		  				buttons: Ext.Msg.OK,
		  				icon: Ext.Msg.ERROR
		  			});
				}
				
		    }
		});
		
		//console.log('ok');
    // commit the changes right after editing finished
    e.record.commit();
});
    
	
    
});